package game.player.ghost;

import game.core.G;
import game.core.Game;
import gui.AbstractGhost;
/**
 * Targets for Ghosts are specified in the method getAction.
 * 
 * TODO: What is the return-statement of getAction really doing?
 *       Implementing intelligent flee-mod for Ghost
 * @author Daniel Dollinger
 *
 */
public class GhostDaniel extends AbstractGhost  {
	private boolean attack;
	@Override
	public int[] getActions(Game game, long timeDue) {
		int[] directions=new int[Game.NUM_GHOSTS];
		
	
		for(int i=0;i<directions.length;i++)
		{
			if (game.isEdible(i))
			{
				attack = false ;
			}
			else
			{
				attack = true;
				
			}
			if(game.ghostRequiresAction(i))			//if it requires an action
			{
				if(attack)
				{
					if(getRandom() > 5)
						directions[i]=game.getNextGhostDir(i,game.getCurPacManLoc(),true,Game.DM.MANHATTEN);
					else
						directions[i]=game.getNextGhostDir(i,game.getCurPacManLoc(),true,Game.DM.PATH);
				}
				else
					directions[i]=game.getNextGhostDir(i,game.getReverse(game.getCurPacManDir()),true,Game.DM.PATH);
				
			}
			else
			{
				int[] activePills = game.getPillIndicesActive();
				int activepill = activePills[i];
				directions[i]=game.getNextGhostDir(i,game.getTarget(i,activePills, true, G.DM.PATH),
						true, Game.DM.PATH);
			}
			
			
		}
		
		
		return directions;
	}
	public static int getRandom() 
	{
		int rand = G.rnd.nextInt(10);
		
		return rand;
	}

	@Override
	public String getGhostGroupName() {
		// TODO Auto-generated method stub
		return "GhostDaniel";
	}

}
